package com.central.common.feign.fallback

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.central.common.entity.Comment
import com.central.common.enum.CommentTypeEnum
import com.central.common.feign.CommentService
import com.central.common.feign.VisitService
import com.central.common.model.CommentRpcDto
import com.central.common.model.CommentVo
import com.central.common.model.PageVo
import com.central.common.model.SysUser
import feign.hystrix.FallbackFactory
import org.slf4j.Logger
import org.slf4j.LoggerFactory

/**
 * @author  fly
 * @date  2021/5/27 17:28
 * @version 1.0
 */
open class CommentServiceFallbackFactory : FallbackFactory<CommentService>{

    private val log: Logger = LoggerFactory.getLogger(CommentServiceFallbackFactory::class.java)


    override fun create(p0: Throwable?): CommentService = object : CommentService {

        override fun insertComment(commentRpcDto: CommentRpcDto): Comment? {

            log.error("添加评论失败, 失败原因是$p0")
            return null
        }

        override fun getCommentVoListByRelevanceId(relevanceId: Long, sysUser: SysUser, pageVo: PageVo, commentTypeEnum: CommentTypeEnum): Page<CommentVo>? {

            log.error("获取$relevanceId 的评论信息失败, 失败原因是$p0")
            return null
        }

        override fun getCommentNumByRelevanceId(relevanceId: Long, commentTypeEnum: CommentTypeEnum): Long {

            log.error("获取$relevanceId 的评论数量失败, 失败原因是$p0")
            return 0L
        }

        override fun getCommentVoListByUserId(userId: Long, commentTypeEnum: CommentTypeEnum): List<Comment>? {

            log.error("获取$userId 的评论信息失败, 失败原因是$p0")
            return null
        }

        override fun getCommentAllUserIds(commentTypeEnum: CommentTypeEnum, pageVo: PageVo): Page<Long>?{

            log.error("获取${commentTypeEnum.msg} 类型的全部评论人失败, 失败原因是$p0")
            return null
        }

        override fun getCommentByContentAndUserIdAndTypeAndRelevanceId(
            content: String,
            userId: Long,
            commentTypeEnum: CommentTypeEnum,
            relevanceId: Long
        ): Comment? {

            log.error("获取${commentTypeEnum.msg} 类型的评论信息失败, 失败原因是$p0")
            return null
        }

    }
}
